package kr.or.javacafe.jyhong;

public class Ant {
	String firstLine;
	public Ant() {
		firstLine = "11";
	}
	
	public void print(int line) {
		int start = 1;

		System.out.println("["+start+"]  "+firstLine);
		String oldString = firstLine;
		
		for (int i = start+1; i <= line; i++) {
			String newString = "";
			int index = 0;
			int count = 0;
			char compare;

			newString += oldString.charAt(index);
			compare = oldString.charAt(index);
			count++;
			index++;
			
			while(index<=oldString.length()-1){
				if(compare==oldString.charAt(index)){
					count++;
				}else {
					newString += count;
					newString += oldString.charAt(index);
					count = 1;
				}
				if(index==oldString.length()-1) {
					newString += count;
				}
				compare = oldString.charAt(index);
				index++;
			}
			System.out.println("["+i+"]  "+newString);
			oldString = newString;		
		}
	}

}
